<html>
	<head>
		<title>baidudl</title>

		<script src="/resource/angular.min.js"></script>
		<script src="/popup/controller.js"></script>
		<style>
			#copy {
				opacity: 0;
				position: 'fixed'
			}
			body {
				min-width: 800px;
			}
		</style>
	</head>

	<body>
		<div id='app' ng-app="popup" ng-csp ng-controller='control'>
			<div style="overflow: auto">
				<div style="margin: 10px 10px;text-align:right;float:left">
					<button style="width: 80px" ng-click="openOptionPage()">Options</button>
				</div>
				<div style="margin: 10px 10px;text-align:right;float:left">
					<button style="width: 80px" ng-click="clear()">Refresh</button>
				</div>
				<div style="margin: 10px 20px;text-align:right;float:right">
					<strong>RPC Address</strong>
					<select ng-model="rpc" ng-options="rpc.protocol+'://'+rpc.host+':'+rpc.port+'/jsonrpc' for rpc in background.config.rpcList" ng-change="rpcChange()"></select>
				</div>
			</div>
			<table>
				<tr>
					<td><button ng-hide="pageCheck()" ng-click="checkAll()">CheckAll</button></td>
					<td style="width: 300px">FileName</td>
					<td style="width: 50px">GLinks</td>
					<td><button style="width: 60px" ng-click="copyAll('glink')">CopyAll</button></td>
					<td style="width: 50px">HLinks</td>
					<td><button style="width: 60px" ng-click="copyAll('hlink')">CopyAll</button></td>
					<td><button style="width: 100px" ng-click="downloadAll()">RPCDownloadAll</td>
					<td><button ng-hide="pageCheck()" ng-click="generate()">Generate</td>
				</tr>
				<tr ng-repeat="x in fileList">
					<td><input type="checkbox" ng-hide="pageCheck()||x.isdir" ng-model="x.check"></td>
					<td><input style="width: 300px" type="text" value={{x.name}} ng-disabled="true"></td>
					<td ng-switch={{x.isdir}}>
						<input style="width: 50px" type="text" value={{x.glink}} ng-disabled="true" ng-switch-when=0>
						<input style="width: 50px" type="text" value='NA' ng-disabled="true" ng-switch-default>
					</td>
					<td><button style="width:60px" ng-click="copy($index, 'glink')">Copy</button></td>
					<td ng-switch={{x.isdir}}>
						<input style="width: 50px" type='text' value={{x.hlinks[0]}} ng-disabled="true" ng-switch-when=0>
						<input style="width: 50px" type='text' value='NA' ng-disabled="true" ng-switch-default>
					</td>
					<td><button style="width: 60px" ng-click="copy($index, 'hlink')">Copy</button></td>
					<td><button style="width: 100px" ng-click="download($index)" ng-hide="x.isdir">RPCDownload</td>
				</tr>
			</table>
			<div><button ng-click="prev()">&lt;</button>{{page.pageno}}<button ng-click="next()">&gt;</button></div>
			<div ng-disabled="!vcode" ng-hide="!vcode">
				<img ng-src='https://pan.baidu.com/genimage?{{vcode}}'>
				<input type="text" ng-model="input">
				<button ng-click="verify(input)">verify</button>
				<button ng-click="refresh(input)">refresh</button>
			</div>
			<pre id='log' style='overflow:scroll;max-height:100px;border-style:solid;border-width:1px;margin-right:50px'>{{message}}</pre>
		</div>
		<textarea id="copy"></textarea>
	</body>
	<script src="/popup/utils.js"></script>
</html>

